# -*- coding: utf-8 -*-
# @Time    : 2023/6/3 14:54
# @Author  : zjf
# @Email   : zjf@163.com
# @File    : setup_page.py
# @Software: PyCharm
from pages.base_page import BasePage
from tools import driver
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy as By
from time import sleep
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import  expected_conditions as EC

class SetupPage(BasePage):
    check_updates_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/user_setting_update_app_layout\"]') #检查更新按钮
    clear_the_cache_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/main_center_clear_cache_layout\"]') #清除缓存按钮
    wangluozhenduan_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/layout_diagnose_network\"]')#网络诊断按钮
    fenxiangxiachufang_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/profile_share_app_layout\"]')#分享下厨房按钮
    zhengzhaozhongxin_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/tv_certification_center\"]') #证照中心
    disanfanggongxiangqingdan_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/tv_other_info_share\"]')#第三方共享清单
    gerenxinxishoujiqingdan_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/tv_personal_info_collect\"]')#个人信息收藏清单
    yingsizhengce_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/tv_privacy_policy\"]')#隐私政策
    yonghuxieyi_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/tv_user_protocol\"]')#用户协议
    bangzhu_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/main_center_help_feedback_layout\"]')#帮助与反馈
    bofangshezhi_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/tv_play_set\"]')#播放设置
    shezhi_locator = (By.XPATH,'//*[@resource-id="com.xiachufang:id/dt_set"]')#设置按钮
    update_locater = (By.XPATH,'//*[@text="当前已是最新版本"]')
    cache_locater = (By.XPATH,'//*[@text="清除缓存成功"]')
    copy_locater = (By.XPATH,'//*[@content-desc="拷贝链接"]/android.widget.ImageView[1]')
    copy_text_locater = (By.XPATH,'//*[@text="链接已复制到剪切板"]')

#点击设置按钮
    def click_setup(self):
        self.find_element(self.shezhi_locator).click()
#点击检查更新按钮
    def add_check_update(self):
        self.find_element(self.check_updates_locator).click()
 #点击清除缓存按钮
    def add_clear_the_cache(self):
        self.find_element(self.clear_the_cache_locator).click()
#点击网络诊断按钮
    def network_diagnosis(self):
        self.find_element(self.wangluozhenduan_locator).click()
#点击分享下厨房按钮
    def share_app(self):
        self.find_element(self.fenxiangxiachufang_locator).click()
#点击拷贝链接
    def copy(self):
        self.find_element(self.copy_locater).click()
#点击证照中心按钮
    def license_center(self):
        self.find_element(self.zhengzhaozhongxin_locator).click()
#点击第三方共享清单按钮
    def third_party_list(self):
        self.find_element(self.disanfanggongxiangqingdan_locator).click()
#点击个人信息收藏清单
    def personal_collect_list(self):
        self.find_element(self.gerenxinxishoujiqingdan_locator).click()
#点击隐私政策按钮
    def privacy_policy(self):
        self.find_element(self.yingsizhengce_locator).click()
#点击用户协议按钮
    def add_yonghuxieyi(self):
        self.find_element(self.yonghuxieyi_locator).click()
#点击帮助与反馈按钮
    def help_and_feedback(self):
        self.find_element(self.bangzhu_locator).click()
#点击播放设置按钮
    def play_setting(self):
        self.find_element(self.bofangshezhi_locator).click()
#获取更新弹框文本
    def get_update_text(self):
        return self.find_element(self.update_locater).text
#获取清除缓存弹框文本
    def get_clear_text(self):
        return self.find_element(self.cache_locater).text
#获取拷贝弹框文本
    def get_copy_text(self):
        return self.find_element(self.copy_text_locater).text
